<!DOCTYPE html>
<html lang = "en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Vue test</title>

  
    <style>
        .active{
            border: 1px solid red;
        }
    </style>

</head>

<body>
    <h1>Hello, World!</h1>
    <!-- 主体部分 -->
    <section id="todoapp">
        <!-- 输入框 -->
        <header class="header">
            <h1>TODO</h1>
            <input autofocus="autofocus" autocomplete="off" placeholder="请输入任务"
                v-model = "inputValue"
                @keyup.enter = "add"
                clase ="new-todo">
        </header>
        <!-- 列表区域 -->
        <section >
            <ul>
                <li v-for="(i,index) in list">
                    <span>{{index+1}}</span>
                    <label >{{i}}</label>
                    <button @click = "remove(index)"> x </button>
                </li>
            </ul>
        </section>
        <!-- 统计和清空 -->
        <footer v-show="list.length != 0">
            <span>{{list.length}} 个</span>
            <button @click = "clear">clear</button>
        </footer>
    </section>
    <!-- vue.js -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        //vue.js代码
        var app=new Vue({
            el:"#todoapp",
            data:{
                list:["eat","sleep","debug"],
                inputValue:"请输入任务TODO"
            },
            methods:{
                add:function(){
                    this.list.push(this.inputValue);
                },
                remove:function(index){
                    this.list.splice(index,1);
                },
                clear:function(){
                    this.list = [];
                }
            }

        })
    </script>
</body>

</html>